<template>
    <div class="item">
        <h6>底层组件-{{ data }}-{{ count }}</h6>
        <button @click="clickBtn">点击底层组件</button>
    </div>
</template>

<script setup lang="ts">

//从vue包引入inject方法
import {inject} from 'vue'

//通过inject方法接收顶层组件传递的数据
//inject(provide定义的数据名称)
const data=inject<string>('parentData')
const count=inject<number>('count')
const method=inject<any>('changeCount')

function clickBtn(){
    method()
}

</script>

<style scoped lang="less">
.item{
    width: 100%;
    height: 200px;
    background-color: blue;
}
</style>